<template>
	<view class="content">
		<navBar>
			<template @click="backPage()" slot="left">
				<u-icon name="arrow-left" color="#fff"></u-icon>
			</template>
			<template class="centerText" slot="center">
				<view class="" style="color: #fff">入库记录详情</view>
			</template>
		</navBar>
		<!-- 信息录入 -->
		<view class="information_entry">
			<!-- <u-read-more  :showHeight="200" ref="uReadMore"  @load="load" > -->
			<u--form labelPosition="left" ref="uForm" labelWidth="80" :model="formData">
				<u-form-item label="日期" borderBottom ref="item1">
					<u--input v-model="formData.create_time" disabled disabledColor="#ffffff" border="none"></u--input>
				</u-form-item>
				<u-form-item label="单号" borderBottom ref="item1">
					<u--input v-model="formData.receipt_no" disabled disabledColor="#ffffff" border="none"></u--input>
				</u-form-item>
				<u-form-item label="仓库" borderBottom ref="item1">
					<u--input v-model="formData.ware_name" disabled disabledColor="#ffffff" border="none"></u--input>
				</u-form-item>
				<!-- <u-form-item label="总数量" borderBottom ref="item1">
					<u--input v-model="formData.detail_count" disabled disabledColor="#ffffff" border="none"></u--input>
				</u-form-item> -->
				<!-- <u-form-item label="供应商" borderBottom ref="item1">
					<u--input v-model="formData.supplier_name" disabled disabledColor="#ffffff"
						border="none"></u--input>
				</u-form-item> -->
				<u-form-item label="入库类型" borderBottom ref="item1">
					<!-- <u--input v-model="formData.receipt_type" disabled disabledColor="#ffffff" border="none"></u--input> -->
					{{formData.receipt_type | parserPutInType}}
				</u-form-item>
			</u--form>
			<!-- </u-read-more> -->
		</view>
		<!-- 物料清单 -->
		<view class="cargo_list">
			<view style="padding-bottom: 30rpx; border-bottom: 1rpx solid #dadbde">
				<text class="big_title">物料清单</text>
				<!-- <text class="tips">轻触完善信息 | 左滑移除</text> -->
			</view>
			<view class="goods_item" v-for="item,index in goodsList" :key="item.detail_id">
				<view style="display: flex; align-items: center;">
					<image :src=" item.goods_img ? item.goods_img : defaultImg" mode=""></image>
					<view class="info">
						<view class="left_info">
							<view class="goodsName hidden_text">
								{{item.goods_name}}
							</view>
							<view class="goodsNum">
								{{item.goods_no}}
							</view>
							<view class="goods_price">
								￥{{item.price}}
							</view>
						</view>
					</view>
				</view>
				<view class="goods_num">
					x{{item.real_quantity}}
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import navBar from '@/components/navBar.vue';
	import {
		getGoodsByRecordIdApi
	} from '@/api/receiveAndBorrow.js'
	export default {
		data() {
			return {
				formData: {
					amount: '',
					create_time: '',
					ware_id: this.$store.state.user.stashInfo.ware_id,
					supplier_name: '',
					receipt_no: '', // 物料编码
					receipt_type: '', //类型
				},
				defaultImg: '/static/images/shixiao.png',
				goodsList: []
			};
		},

		components: {
			navBar,
		},
		onLoad(e) {
			if (e.info) {
				const parseData = JSON.parse(e.info)
				this.formData = parseData
				this.getGoodsByRecordId(parseData.id)
			}
		},
		methods: {
			backPage() {
				uni.navigateBack();
			},
			async getGoodsByRecordId(id) {
				const {
					data: {
						data
					}
				} = await getGoodsByRecordIdApi({
					receipt_id: id,
					page: 1,
					pageSize: 100
				})
				this.goodsList = data
			}
		},
	};
</script>

<style lang="scss" scoped>
	.content {
		background-color: #f3f4f6;
		min-height: 100vh;
		padding-bottom: 20rpx;
		box-sizing: border-box;

		.top_box {
			height: 200rpx;

			.title {
				margin: 40rpx 0 20rpx 60rpx;
				font-size: 40rpx;
				font-weight: 600;
			}

			::v-deep .u-steps-item__wrapper--row {
				background-color: #b3d7ff;
			}
		}

		.information_entry {
			background-color: #fff;
			margin: 10rpx;
			padding: 30rpx 20rpx;
			border-radius: 20rpx;

			::v-deep .u-form-item__body__left {
				margin-left: 20rpx;
			}

			::v-deep .u-upload__wrap__preview {
				width: 110rpx;
				height: 110rpx;
			}

			::v-deep .u-upload__wrap__preview__image {
				width: 110rpx !important;
				height: 110rpx !important;
			}
		}

		.cargo_list {
			background-color: #fff;
			border-radius: 20rpx;
			min-height: 700rpx;
			margin: 0 10rpx;
			padding: 20rpx;

			.big_title {
				font-weight: 700;
				font-size: 35rpx;
			}

			.tips {
				margin-left: 40rpx;
				font-size: 25rpx;
				color: #f9b85c;
			}

			.empty_box {
				margin: 40rpx 0;
			}

			.goods_item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 20rpx;
				border-bottom: 1px solid #dadbde;

				image {
					width: 80rpx;
					height: 80rpx;
				}

				.info {
					display: flex;
					justify-content: space-between;
					align-items: center;

					.left_info {
						margin-left: 20rpx;
						width: 400rpx;

						.goodsName {
							font-size: 30rpx;
						}

						.goodsNum {
							font-size: 26rpx;
							color: #f9b85c;
						}

						.goods_price {
							font-size: 26rpx;
						}
					}

				}
			}
		}
	}
</style>